package com.yezong.AidMe.mapper;

import com.yezong.AidMe.entity.CtUser;
import com.yezong.AidMe.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserMapper {

    @Select("select * from user where id=#{id}")
    User selectOneById(Integer id);

    @Select("select * from user where phonenumber=#{phonenumber} and password=#{password}")
    User selectOneByPhonenumberAndPassword(User user);

    @Select("select interest from user where id=#{id}")
    String selectInterest(Integer id);

    @Insert("insert into user(name,password,sex,phonenumber,interest,location,photo,number) values(#{name},#{password},#{sex},#{phonenumber},#{interest},#{location},#{photo},#{number})")
    int insertUser(User user);

    @Update("update user set name=#{name},password=#{password},sex=#{sex},phonenumber=#{phonenumber},interest=#{interest},location=#{location},photo=#{photo}")
    int updateUser(User user);

    @Delete("delete form where id = #{id}")
    int deleteUser(int id);

    @Select("select * from ctuser where school=#{school} and college=#{college} and major=#{major} and name = #{name} and number=#{number} and password=#{password}")
    CtUser certifyStudentInfo(CtUser ctUser);

    @Update("update ctuser set cted=1 where number=#{number}")
    int updateStudentCertifiedInfo(String number);

    @Update("update user set cted=1,number=#{number} where id=#{id}")
    int updateUserCertifiedInfo(int id, String number);

}
